package com.shd.edanpei.presenter;

import com.google.gson.reflect.TypeToken;
import com.shd.edanpei.base.BasePresenterImpl;
import com.shd.edanpei.common.Constant;
import com.shd.edanpei.bean.NeedBean;
import com.shd.edanpei.presenter.contract.SelectContract;
import com.shd.edanpei.util.GsonUtil;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by mc on 2018/8/16.
 * yang-wen-wen
 */

public class SelectPresenter extends BasePresenterImpl<SelectContract.SelectIView>
        implements SelectContract.SelectIPresenter {

    public SelectPresenter(SelectContract.SelectIView mView) {
        super(mView);
    }

    @Override
    public void getListData(int type, String data) {
        List<NeedBean> list = null;
        if (!data.isEmpty()) {
            Type type1 = new TypeToken<List<NeedBean>>() {
            }.getType();
            list = GsonUtil.toList(data, type1);
        }

        if (list == null || list.size() == 0) {
            list = new ArrayList<>();

            switch (type) {
                case Constant.REPAY_WAY:
                    list.add(new NeedBean("先息后本", false));
                    list.add(new NeedBean("等额本息", false));
                    list.add(new NeedBean("随借随还", false));
                    list.add(new NeedBean("其他", false));
                    break;
                case Constant.NEED_DATA:
                    list.add(new NeedBean("户口本", false));
                    list.add(new NeedBean("结婚证/离婚证", false));
                    list.add(new NeedBean("房产证/不动产证", false));
                    list.add(new NeedBean("车辆登记证/行驶证", false));
                    list.add(new NeedBean("车辆保单", false));
                    list.add(new NeedBean("公司营业执照", false));
                    list.add(new NeedBean("其他房产证", false));
                    list.add(new NeedBean("征信", false));
                    break;
                case Constant.HOUSE_NATURE:
                    list.add(new NeedBean("住宅", false));
                    list.add(new NeedBean("别墅", false));
                    list.add(new NeedBean("排屋", false));
                    list.add(new NeedBean("商铺", false));
                    list.add(new NeedBean("写字楼", false));
                    list.add(new NeedBean("厂房", false));
                    list.add(new NeedBean("土地", false));
                    list.add(new NeedBean("酒店式公寓", false));
                    break;
            }
        }

        mBaseIView.getAdapter().setNewData(list);
    }
}
